home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / attrPresetEditWin.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  4.9 KB  |  176 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //
  22. //  Creation Date:  2001 
  23. //  Author:         dbrins 
  24. //
  25. //<doc>
  26. //<name attrPresetEditWin>
  27. //<owner "Alias|Wavefront Unsupported">
  28. //
  29. //<synopsis>
  30. //        attrPresetEditWin nodeType 
  31. //
  32. //<returns>
  33. //        None.    
  34. //
  35. //<description>
  36. //        Opens the attribute preset editor window. This allows
  37. //        one to delete presets for a given node type.
  38. //        The initial node type to display must be specified.
  39. //
  40. //<examples>
  41. //      attrPresetEditWin "transform"
  42. //      attrPresetEditWin "brush"
  43. //</doc>
  44.  
  45.  
  46.  
  47. global string $gApeWinPresetList = "";
  48. global string $gApeWinNodeType = "";
  49.  
  50. global proc deleteSelectedAttrPresets(){
  51.     global string $gApeWinPresetList;
  52.     global string $gApeWinNodeType;
  53.  
  54.     if( "" == $gApeWinPresetList ){
  55.         return;
  56.     }
  57.     if( "" == $gApeWinNodeType ){
  58.         return;
  59.     }
  60.  
  61.     string $nodeType = $gApeWinNodeType;
  62.     string $ppath = `internalVar -userPrefDir`;
  63.     $ppath = substitute( "prefs", $ppath, "presets/attrPresets");
  64.     $ppath  = $ppath + $nodeType; 
  65.  
  66.     string $selectedPresets[] = `textScrollList -q -si $gApeWinPresetList`;
  67.     string $preset;
  68.     for( $preset in $selectedPresets ){
  69.         sysFile -delete ($ppath + "/" + $preset + ".mel" );
  70.     }
  71.     if( size($selectedPresets) > 0 ){
  72.         updateAPEWinNodetype( $nodeType );
  73.     }
  74. }
  75.  
  76. //
  77. // reset the nodetype being displayed by the attrPresetEditWin
  78. //
  79. global proc updateAPEWinNodetype( string $nodeType ){
  80.     global string $gApeWinPresetList;
  81.     global string $gApeWinNodeType;
  82.  
  83.     if( !`window -exists attrPresetEditWin` ) {
  84.         return;
  85.     }
  86.     if( "" == $gApeWinPresetList ){
  87.         return;
  88.     }
  89.     $gApeWinNodeType = $nodeType;
  90.     string $windowTitle = "Edit " + $nodeType + " Presets";
  91.     window -e -t $windowTitle attrPresetEditWin;
  92.  
  93.     string $ppath = `internalVar -userPrefDir`;
  94.     $ppath = substitute( "prefs", $ppath, "presets/attrPresets");
  95.     $ppath  = $ppath + $nodeType; 
  96.     textScrollList -e -ra $gApeWinPresetList;
  97.     if( `file -q -ex $ppath` ){
  98.         string $files;
  99.         if( `about -nt` ){
  100.             $files = `system ( "dir /b \"" + $ppath +"\"")`;
  101.         } else if (`about -irix` || `about -linux` || `about -mac`) {
  102.             $files = `system ( "ls " + $ppath )`;
  103.         } else {
  104.             warning( "Operating system unrecognized." );
  105.         }
  106.     
  107.         string $fileList[];
  108.         int $numTokens = tokenize( $files, $fileList );
  109.         // create Directory for current node type
  110.         if ($numTokens > 0 && !($numTokens == 1 && $fileList[0] == "unknown")) {
  111.             string $file;
  112.             for ( $file in $fileList ) {
  113.                 // only show .mel files
  114.                 if( size( match( ".mel", $file ) ) ){
  115.                     string $presetName = `substitute ".mel" $file ""`;
  116.                     textScrollList -e -append $presetName $gApeWinPresetList;
  117.                 }
  118.             }
  119.         }
  120.     }
  121.  
  122. }
  123.  
  124. //
  125. // Open the attribute Preset Editor
  126. //
  127. global proc attrPresetEditWin( string $nodeType )
  128. {
  129.     global string $gApeWinPresetList;
  130.     global string $gApeWinNodeType;
  131.     if( !`window -exists attrPresetEditWin` ) 
  132.     {
  133.         string $windowTitle = "Edit " + $nodeType + " Presets";
  134.         window -t $windowTitle -iconName "Edit Presets" -w 410 -h 150 attrPresetEditWin;
  135.         formLayout fl;
  136.  
  137.         setParent -m ..;
  138.  
  139.         $gApeWinPresetList = `textScrollList -allowMultiSelection true psetList`;
  140.         separator -horizontal true shelfSeparator;
  141.         button
  142.             -annotation "delete selected presets"
  143.             -l "Delete"
  144.             -c  "deleteSelectedAttrPresets()"
  145.             deleteAttrPresetButton;
  146.         button
  147.             -label "Close"
  148.             -c "window -e -visible false attrPresetEditWin" 
  149.             closeAttrPresetEdButton;
  150.  
  151.  
  152.         formLayout -e
  153.             -af shelfSeparator "left" 0
  154.             -af shelfSeparator "right" 0
  155.             -ac shelfSeparator "bottom" 5 closeAttrPresetEdButton
  156.  
  157.             -af psetList    "top" 5
  158.             -af psetList    "left" 5
  159.             -af psetList    "right" 5
  160.             -ac psetList    "bottom" 5 shelfSeparator
  161.  
  162.             -af deleteAttrPresetButton "left" 5
  163.             -af deleteAttrPresetButton "bottom" 5
  164.             -ap deleteAttrPresetButton "right" 3 50
  165.             -an deleteAttrPresetButton "top"
  166.  
  167.             -ap closeAttrPresetEdButton "left" 2 50
  168.             -af closeAttrPresetEdButton "bottom" 5
  169.             -af closeAttrPresetEdButton "right" 5
  170.             -an closeAttrPresetEdButton "top"
  171.             fl;
  172.     }
  173.     updateAPEWinNodetype( $nodeType );
  174.     showWindow attrPresetEditWin;
  175. }
  176.